<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>

</body>
<script>
    /**
     * a-b 升序
     * b-a 降序
     */
    let arr = [2, 3, 4, 1, 5, 11];
    arr.sort(function(a, b) {
        console.log(a, b);
        //return a - b; //升序
        return b - a; //降序 5 - 11 = -6 < 0  ==> a在前,11在前
    });
    console.log(arr)
</script>

</html>